package com.sunjy.common.utils;

/**
 * @author: snowwolf-louis.
 * @date: 18/9/4.
 * @desc: 脱敏工具包
 */
public class DesensitizationUtil {
    public static String getDesensiPhoneNumber(String phoneNumber) {
        if (StringUtils.isBlank(phoneNumber)) {
            return "";
        }

        StringBuilder sb = new StringBuilder();

        sb.append(phoneNumber.substring(0, 3))
                .append("****")
                .append(phoneNumber.substring(phoneNumber.length() - 4));

        return sb.toString();
    }

    public static String getDesensiNickName(String nickName){
        if (StringUtils.isBlank(nickName)){
            return "";
        }

        return new StringBuilder().append("*").append(nickName.substring(1)).toString();
    }


    public static void main(String[] args){
        System.out.print(getDesensiPhoneNumber("18217267935"));
    }
}
